import React from 'react';
import AlertDialog from './AlertDialog';
import { useTranslation } from 'react-i18next';
import { Linking } from 'react-native';

type PermissionNotGrantedDialogProps = {
  visible: boolean;
  onDismiss: () => void;
  onCancel?: () => void;
};

const PermissionNotGrantedDialog: React.FC<PermissionNotGrantedDialogProps> = (
  props
) => {
  const { t } = useTranslation();
  return (
    <>
      <AlertDialog
        visible={props.visible}
        onDismiss={props.onDismiss}
        title={t('message.enablePermission')}
        buttons={[
          {
            title: t('user.logOutCancel'),
            onPress: props.onCancel,
          },
          {
            title: t('common.confirmButtonText'),
            highlighted: true,
            onPress: Linking.openSettings,
          },
        ]}
      />
    </>
  );
};

export default React.memo(PermissionNotGrantedDialog);
